package cn.it62.pojo;

/**
 * @author zhenhuaShen
 * @version 1.0
 * @date 2019/7/31
 * @description cn.it62.pojo
 */
public class Aircraft {

    private String planeName;
    private int oil;
    private int voyage;

    /**
     * 有参构造
     *
     * @param planeName
     * @param oil
     * @param voyage
     */
    public Aircraft(String planeName, int oil, int voyage) {
        setPlaneName(planeName);
        setOil(oil);
        setVoyage(voyage);
    }

    public String getPlaneName() {
        return planeName;
    }

    public void setPlaneName(String planeName) {
        this.planeName = planeName;
    }

    public int getOil() {
        return oil;
    }

    public void setOil(int oil) {
        if (oil < 0) {
            System.out.println("载油量不能为负");
            oil = 100;
        }
        this.oil = oil;
    }

    public int getVoyage() {
        return voyage;
    }

    public void setVoyage(int voyage) {
        if (voyage < 1000) {
            System.out.println("行程不低于1000");
            voyage = 1000;
        }
        this.voyage = voyage;
    }


    public void fly() {
        System.out.println(planeName + "最多能飞" + voyage + "公里");
        System.out.println(planeName + "最大载油量" + oil + "吨");
    }
}
